<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('系统公告管理列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="dept-form">
                <div class="select-list">
                    <ul>
                        <li>
                            标题：<input type="text" name="ntcTitle"/>
                        </li>
                        <li>
                            内容：<input type="text" name="ntcContent"/>
                        </li>
                        <li>
                            类别：<select name="sortCode" onchange="dropChgSendTextOnly(this,'sortName');">
                                <option value="">请选择</option>
                                <option value="11">普通</option>
                                <option value="12">重要</option>
                                <option value="21">紧急</option>
                            </select>
                        </li>
                        <li>
                            来源单位：<input type="text" name="fromDept"/>
                        </li>
                        <li>
                            发布者：<input type="text" name="issueUser"/>
                        </li>
<!--                        <li>-->
<!--                            通知部门：<input type="text" name="objDept"/>-->
<!--                        </li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.addTab()">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.editTab()">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-primary multiple disabled" onclick="$.operate.removeAll()">
                <i class="fa fa-edit"></i> 删除
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = '';
    var removeFlag = '';
    var prefix = ctx + "system/mInterior/cfNotice"

    $(function () {
        var options = {
            sortName:"IssueTime",
            sortOrder:"desc",
            uniqueId: "myPkVal",
            url: prefix + "/afficheListJson",
            createUrl: prefix + "/afficheAdd",
            updateUrl: prefix + "/afficheEdit/{id}",
            removeUrl: prefix + "/afficheRemove",
            modalName: "系统公告",
            columns: [{
                checkbox: true
            },
                {field:'myPkVal',title:'myPkVal',visible:false},
                {field:'NtcTitle',title:'通知标题',align:'center',halign:'center',formatter:function (value, row, index) {
                        return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis
                },
                {field:'SortName',title:'类别',align:'center',sortable:true,},
                {field:'FromDept',title:'来源单位',align:'center'},
                {field:'IssueUser',title:'编辑人',align:'center'},
                {field:'fbFlag',title:'发布',align:'center',sortable:true,formatter: function (value, row, index) {
                        return fmtsysIssue(value,row,index);
                    }
                },
                {field:'fbTime',title:'时间',align:'center'},
                {field:'Remark',title:'备注',align:'center',halign:'center',
                    formatter:function (value, row, index) {
                        return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.myPkVal + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.myPkVal + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });

    function fmtsysIssue(value,row,index){
        var rtn = value;
        var myVal = parseInt(value);
        switch (myVal) {
            case 0:
                rtn = '<div class="spBlue">否</div>';
                break;
            case 1:
                rtn = '<div class="spRed">是</div>';
                break;
            default:
                break;
        }
        return rtn;
    }

</script>
</body>
</html>